package com.t2two.example.controller;

import com.t2two.example.common.dataresult.DataResult;
import com.t2two.example.entity.userinfo.UserInfo;
import com.t2two.example.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @version 1.0
 * @description: TODO
 * @author: lifei
 * @date: 2023/6/26 11:52
 */
@RestController
@RequestMapping("/api/userInfo")
public class UserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    @PostMapping("/testLink")
    public String testLink(UserInfo userInfo){
        return "true";
    }

    @PostMapping("/insertUserInfo")
    public int insertUserInfo(@RequestBody UserInfo userInfo){
        return userInfoService.insertUserInfo(userInfo);
    }

    @GetMapping("/queryById")
    public String queryById(@RequestParam Long guid){
        return userInfoService.queryById(guid);
    }

    @PostMapping("/export/exportTest")
    public void excel(HttpServletResponse response){
        userInfoService.test(response);
    }


    public DataResult sendEmail(){
        return DataResult.success(userInfoService.sendEmail());
    }
}
